package com.campus.controller;

import com.campus.entity.Teacher;
import com.campus.service.TeacherService;
import com.campus.web.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;
    @PostMapping("/insert")
    public ResponseResult addTeacher(@RequestBody Teacher teacher){
        teacherService.insertTeacher(teacher);
        return ResponseResult.ok("添加成功");
    }
    @PostMapping("/id")
    public ResponseResult<Teacher> selectTeacherById( Integer id){
        Teacher teacher = teacherService.selectTeacherById(id);
        return ResponseResult.ok(teacher,"查询成功");
    }
    @PostMapping("/select")
    public ResponseResult<List<Teacher>> selectTeacher(@RequestBody Teacher teacher){
        List<Teacher> teacher1 = teacherService.selectTeacher(teacher);
        return ResponseResult.ok(teacher1,"查询成功");
    }
}
